<?php
$customerReport = Dracosys::getSessionValue(SESSION_INTERFACE, 'CustomerReport');
$headLineCustomerReport = Dracosys::getSessionValue(SESSION_INTERFACE, 'HeadLineCustomerReport');

function getStatusBallPath($EnStatus) {
    $ArStatusImage = array(
        'NORMAL' => 'VerdeEscuro',
        'CANCELADO' => 'Vermelho',
        'LIBERADO' => 'VerdeEscuro',
        'ATRASO' => 'Laranja',
        'CONGELADO' => 'AzulClaro',
        'PRE CONGELADO' => 'AzulEscuro',
        'CONFIRMADO' => 'VerdeEscuro',
        'LANCADO' => 'Cinza',
        'ESTORNO' => 'VerdeFraco'
    );
    return DRA_VIEW_URL . 'images/statustype/' . $ArStatusImage[$EnStatus] . '.png';
}
?>
<h2>Relatório Clientes Inadimplentes</h2>
<section id="DelinquentReport">
    <table id="DelinquentReport_ReportLider" class="Report">
        <thead>
            <tr>
                <th colspan="7">L&iacute;deres</th>
            </tr>
            <tr class="header">
                <td>Status</td>
                <td>Vezes</td>
                <td>Cliente</td>
            </tr>
        </thead>
        <tbody>
            <?php foreach($headLineCustomerReport as $EnStatus => $ReportLine): ?>
                <tr>
                    <td><?=$EnStatus?></td>
                    <td><?=$ReportLine['SituationTimes']?></td>
                    <td><?=$ReportLine['Cliente']->getCustomerName()?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <table id="DelinquentReport_ReportGeral" class="Report hide">
        <thead>
            <tr>
                <th colspan="7">Todos os Clientes</th>
            </tr>
            <tr class="header">
                <td>Cliente</td>
                <td>Atraso</td>
                <td>Pré Congelado</td>
                <td>Congelado</td>
                <td>Situação</td>
            </tr>
        </thead>
        <tbody>
            <?php foreach($customerReport as $Customer):  ?>
            <tr>
                <td><?=$Customer->getCustomerName()?></td>
                <td><?=$Customer->getReport('ATRASO')?></td>
                <td><?=$Customer->getReport('PRE CONGELADO')?></td>
                <td><?=$Customer->getReport('CONGELADO')?></td>
                <td>
                    <img src="<?=getStatusBallPath($Customer->getArGeneralData('EnStatus'))?>" alt="<?=$Customer->getArGeneralData('EnStatus')?>" title="<?=$Customer->getArGeneralData('EnStatus')?>" />
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <table id="DelinquentReport_ReportIndividual" class="Report hide">
        <thead>
            <tr>
                <th colspan="7">Cliente Ativos</th>
            </tr>
            <tr class="header">
                <td>Cliente</td>
                <td>Atraso</td>
                <td>Pré Congelado</td>
                <td>Congelado</td>
                <td>Situação</td>
            </tr>
        </thead>
        <tbody>
            <tr class="header">
                <td>Cliente</td>
                <td>Atraso</td>
                <td>Pré Congelado</td>
                <td>Congelado</td>
                <td>Situação</td>
            </tr>
            <?php foreach($customerReport as $Customer):
                   if( !$Customer->isCancelled() ):
            ?>
                    <tr>
                        <td><?=$Customer->getCustomerName()?></td>
                        <td><?=$Customer->getReport('ATRASO')?></td>
                        <td><?=$Customer->getReport('PRE CONGELADO')?></td>
                        <td><?=$Customer->getReport('CONGELADO')?></td>
                        <td>
                            <img src="<?=getStatusBallPath($Customer->getArGeneralData('EnStatus'))?>" alt="<?=$Customer->getArGeneralData('EnStatus')?>" title="<?=$Customer->getArGeneralData('EnStatus')?>" />
                        </td>
                    </tr>
            <?php
                    endif;
                endforeach; ?>
        </tbody>
    </table>

    <table id="DelinquentReport_ReportCancelled" class="Report hide">
        <thead>
            <tr>
                <th colspan="7">Clientes Cancelados</th>
            </tr>
            <tr class="header">
                <td>Cliente</td>
                <td>Atraso</td>
                <td>Pré Congelado</td>
                <td>Congelado</td>
                <td>Situação</td>
            </tr>
        </thead>
        <tbody>
            <?php foreach($customerReport as $Customer):
                   if( $Customer->isCancelled() ):
            ?>
                    <tr>
                        <td><?=$Customer->getCustomerName()?></td>
                        <td><?=$Customer->getReport('ATRASO')?></td>
                        <td><?=$Customer->getReport('PRE CONGELADO')?></td>
                        <td><?=$Customer->getReport('CONGELADO')?></td>
                        <td>
                            <img src="<?=getStatusBallPath($Customer->getArGeneralData('EnStatus'))?>" alt="<?=$Customer->getArGeneralData('EnStatus')?>" title="<?=$Customer->getArGeneralData('EnStatus')?>" />
                        </td>
                    </tr>
            <?php
                    endif;
                endforeach; ?>
        </tbody>
    </table>

    <div class="pagination">
        <a href="#" rel="ReportLider" class="selected borderRadios">Lideres</a>
        <a href="#" rel="ReportGeral" class="nonselected borderRadios">Todos</a>
        <a href="#" rel="ReportIndividual" class="nonselected borderRadios">Ativos</a>
        <a href="#" rel="ReportCancelled" class="nonselected borderRadios">Cancelados</a>
    </div>
</section>
